/* ===========================================================
 * JFreeChart : a free chart library for the Java(tm) platform
 * ===========================================================
 *
 * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
 *
 * Project Info:  http://www.jfree.org/jfreechart/index.html
 *
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
 * USA.
 *
 * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. 
 * Other names may be trademarks of their respective owners.]
 *
 * --------------------------
 * StackedBarChart3DTest.java
 * --------------------------
 * (C) Copyright 2005-2013, by Object Refinery Limited.
 *
 * Original Author:  David Gilbert (for Object Refinery Limited);
 * Contributor(s):   -;
 *
 * Changes:
 * --------
 * 12-Apr-2005 : Version 1 (DG);
 *
 */



import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.awt.Color;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.text.NumberFormat;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.event.ChartChangeEvent;
import org.jfree.chart.event.ChartChangeListener;
import org.jfree.chart.labels.CategoryItemLabelGenerator;
import org.jfree.chart.labels.CategoryToolTipGenerator;
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
import org.jfree.chart.labels.StandardXYItemLabelGenerator;
import org.jfree.chart.labels.XYItemLabelGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.Plot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.CategoryItemRenderer;
import org.jfree.chart.urls.CategoryURLGenerator;
import org.jfree.chart.urls.StandardCategoryURLGenerator;
import org.jfree.data.Range;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.general.DatasetUtilities;
import org.junit.Before;
import org.junit.Test;

/**
 * Some tests for a stacked bar chart with 3D effect.
 */
public class StackedBar {

    /** A chart. */
    private JFreeChart chart;

    /**
     * Common test setup.
     */
    @Before
    public static void main(String[] args)  {         
        ChartFrame frame = new ChartFrame("Demo",createChart());
		frame.pack();
		frame.setVisible(true);
    } 

   

    /**
     * Create a stacked bar chart with sample data in the range -3 to +3.
     *
     * @return The chart.
     */
    private static JFreeChart createChart() {

        Number[][] data = new Integer[][]
            {{new Integer(5), new Integer(0)},
             {new Integer(0), new Integer(3)},
             {new Integer(0), new Integer(1)},
             {new Integer(0), new Integer(1)}};

        CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S",
                "C", data);
         JFreeChart chart=ChartFactory.createStackedBarChart(
            "Stacked Bar Chart 3D",  // chart title
            "Domain", "Range",
            dataset,      // data
            PlotOrientation.VERTICAL,
            true,         // include legend
            true,
            true
        );
         CategoryPlot plot=(CategoryPlot)chart.getPlot();
         plot.setBackgroundPaint(new Color(240,239,208));
         Paint p1 = new GradientPaint(
                 0.0f, 0.0f, new Color(173, 206, 119), 0.0f, 0.0f, new Color(139, 193, 56)
             );
         Paint p2 = new GradientPaint(
                 0.0f, 0.0f, new Color(114, 203, 243), 0.0f, 0.0f, new Color(0, 171, 211)
             );
         Paint p3 = new GradientPaint(
                 0.0f, 0.0f, new Color(226, 220, 208), 0.0f, 0.0f, new Color(192, 176, 151)
             );
         Paint p4 = new GradientPaint(
                 0.0f, 0.0f, new Color(168, 174, 224), 0.0f, 0.0f, new Color(2,80,146)
             );
         plot.getRenderer().setSeriesPaint(0, p3);
         plot.getRenderer().setSeriesPaint(2, p2);
         plot.getRenderer().setSeriesPaint(1, p1);
         plot.getRenderer().setSeriesPaint(3, p4);
         NumberFormat format = NumberFormat.getNumberInstance();         
         format.setMaximumFractionDigits(2);
         StandardCategoryItemLabelGenerator generator =  new StandardCategoryItemLabelGenerator("{2}M",format);     
         plot.getRenderer().setBaseItemLabelPaint(Color.WHITE);
         plot.getRenderer().setBaseItemLabelFont(new Font("Arial Black", Font.BOLD, 20));
         plot.getRenderer().setBaseItemLabelsVisible(true);
         plot.getRenderer().setBaseItemLabelGenerator(generator);
         
         return chart;

    }

    
}
